package com.swift.authority.common.util;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
 * @author Administrator
 * @description :
 * @date 2022/06/19 10:40
 * @since open jdk 1.8
 */
public class Base64Util {
    private Base64Util() {}

    /**
     * 加密JDK1.8
     */
    public static String encode(byte[] str) throws UnsupportedEncodingException {
        byte[] encodeBytes = Base64.getEncoder().encode(str);
        return new String(encodeBytes);
    }

    /**
     * 解密JDK1.8
     */
    public static  byte[] decode(String str) throws UnsupportedEncodingException {
        byte[] decodeBytes = Base64.getDecoder().decode(str.getBytes("utf-8"));
        return decodeBytes;
    }
}
